Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

300
Visualizações
Why Does EPPlus Excel Library in AWS Lambda Environment Throw "The type initializer for 'Gdip' threw an exception"

Posting this question for others experiencing the same issue. My answer below.

I created an AWS Lambda method that receives a series of query parameters that are used to produce a report. The report data is saved in an Excel file using the excellent EPPlus library. When I run the code in the development environment it executes without a problem. After I deploy the code to AWS and call it via the URL I get the following exception:

The type initializer for 'Gdip' threw an exception

Why would this happen after deployment, yet run properly in the development environment?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

What I was able to determine is that the error occurs when attempting to automatically size column widths to fit the supplied data in one of the worksheets. EPPlus helpfully supplies an AutoFitColumns method for a range that will size the columns based on the widest data in the range. Once I pinpointed this line of code as the source of the exception it all made sense.

I have not confirmed this, but I assume that EPPlus loops through the text in each cell of the range and calls the .Net Graphics.MeasureString method from the System.Drawing namespace to determine the width of the rendered text. Once the widest string is determined the column width is set accordingly.

The problem is that it appears that the GDI+ API is not available in the AWS lambda environment. I believe you can add libgdiplus to your AWS Lambda environment (see forum discussions here and here). However, I did not attempt to change my configuration, instead opting for default column widths with word wrap enabled.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda